package csdn;

public class Csdn1 {
    public static int num(){
        try {
            return 10;
        }
        catch (Exception e){
            return 0;
        }
        finally {
            return 100;
        }
    }
    public static void main(String[] args) {
        System.out.println(num());
    }
    public static int divide(int x,int y)throws ArithmeticException{
        if(y==0){
            throw new ArithmeticException("抛出0异常");
        }
        return x/y;
    }
    public static void main6(String[] args) {
        System.out.println(divide(50,1));
    }
    public static void main5(String[] args) {
        int arr[]={1,2,3,4,5,6,7};
        try {
            System.out.println("before");
            System.out.println(arr[10]);
            System.out.println("after");
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
    public static void main4(String[] args) {
        try {
            System.out.println(10/0);
        }
        catch (ArithmeticException e){
            e.printStackTrace();
            System.out.println("分母不能为0");
        }
    }
    public int num = 10;
    public static void main3(String[] args) {
        Csdn1 t = null;
        System.out.println(t.num);
    }
    public static void main2(String[] args) {
        int arr[]={1,2,3,4,5,6};
        System.out.println(arr[9]);
    }
    public static void main1(String[] args) {
        System.out.println(15/2);
    }
}
